/**
 * 
 */
package com.thon.dao.user.impl;


import org.springframework.stereotype.Repository;

import com.thon.dao.user.CharitarianDao;
import com.thon.dao.user.InstitutionDao;
import com.thon.dao.util.AbstractDao;
import com.thon.dao.util.Page;
import com.thon.entity.user.Charitarian;
import com.thon.entity.user.Institution;

/**
* @File: CharitarianDaoImpl.java
* @author zemo 
* @mail chenzeming@lanbaoo.com
* @date: Feb 14, 2014 11:36:33 PM
* @Description: TODO
 */
@Repository
public class CharitarianDaoImpl extends AbstractDao<Charitarian> implements CharitarianDao{
	
	public CharitarianDaoImpl(){
		super(Charitarian.class);
	}

	@Override
	public Page<Charitarian> findCharitarian(Page<Charitarian> page, Byte status) {
		String queryString;
		if(status==0)
		{	
			queryString = "FROM Charitarian";
		return findPage(page, queryString);
		}
		queryString = "FROM Charitarian WHERE status = ?";
		return findPage(page, queryString, status);
	}

	@Override
	public Charitarian getCharitarianByUser(int userId) {
		
		String queryString = "FROM Charitarian WHERE user.id = ? and status != 0";
		return findOne(queryString, null, userId);
	}


}
